package com.dc.dbus.transport.rabbitmq;


import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

public class RabbitMqManager {
	
	protected final ConnectionFactory cf;
	protected final RabbitAdmin admin;
	protected final RabbitTemplate template;
	
	public RabbitMqManager(String mqHost, int mqPort) {
		
		cf = new CachingConnectionFactory(mqHost, mqPort);
		admin = new RabbitAdmin(cf);
		template = new RabbitTemplate(cf);
		
		template.setChannelTransacted(false);
	}
	
	public ConnectionFactory getCf() {
		return cf;
	}

	public RabbitAdmin getAdmin() {
		return admin;
	}

	public RabbitTemplate getTemplate() {
		return template;
	}

}
